<template>
  <div class="rowThreeColText">
    <template v-for="(item, index) in widgetData.value">
      <div class="image" :class="{ Border: type == 'waterfall' && customMadeSiteCode == item.siteId }"
        :id="type == 'waterfall' ? item.siteId : ''" :key="index" @click="configData($event, item, widgetData)">
        <!-- 热力图 -->
        <template v-for="(ele, idx) in mapData">
          <div v-if="ele.sitePageId == item.siteId" :key="idx + 'a'" class="mark"
            :style="{ background: `#${ele.color}`, opacity: 0.9 }">
            <div>
              <div class="name">PV：{{ ele.exposurePv }}</div>
              <div class="name">UV：{{ ele.exposureUv }}</div>
            </div>
            <div class="level">Lv.{{ ele.level }}</div>
          </div>
        </template>
        <template v-if="item.url != ''">
          <div class="img"><img :src="item.url"></div>
          <div class="title"><span>{{ item.title }}</span></div>
        </template>
        <template v-else>
          <i class="el-icon-picture"></i>
          <div class="title"><span>{{ item.title }}</span></div>
        </template>
      </div>
    </template>
  </div>
</template>

<script>
export default {
  name: "rowThreeColText",
  props: {
    type: {
      type: String,
      default: 'widget'
    },
    widgetData: {
      type: Object,
      required: true
    },
    customMadeSiteCode: {
      type: String,
      default: ''
    },
    // 热力图
    mapData: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {

    }
  },
  methods: {
    configData(e, item, items) {
      this.$emit('configData', e, item, items)
    }
  },
}
</script>

<style lang="scss" scoped>
.rowThreeColText {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;

  .image {
    width: 32.6%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px dashed #000;
    border-left: 1px dashed #000;
    margin-left: 10px;
    position: relative;

    // 热力图
    .mark {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      padding: 10px 15px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .name {
        color: #ffffff;
      }

      .level {
        color: #ffffff;
        text-align: right;
      }
    }

    &:nth-child(1) {
      border-left: unset;
      margin-left: 0;
    }

    &:nth-last-child(1) {
      border-right: unset;
    }

    .img {
      width: 100%;
      height: calc(100% - 40px);

      img {
        width: 100%;
        height: 100%;
      }
    }

    .title {
      width: 100%;
      height: 40px;
      line-height: 40px;
      font-size: 18px;
      padding: 13px;
      background: #000;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      color: #fff;

      span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    .el-icon-picture {
      width: 100%;
      height: 100%;
      font-size: 3.125rem;
      background: #ffffff;
      color: #c1c1c1;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }

  // 选中样式
  .Border {
    border: 2px dashed red !important;
    padding: 5px;
  }

  // 锚点定位
  .anchor {
    box-shadow: 1px 1px 10px 10px red;
  }
}
</style>